Filter for text attribute that contains certain value

I am trying to use filters for the first time.  I've seen that you are able to filter on attributes, but I'm not sure how to set up a filter in which an attribute contains a particular value.  I've tried running the following code:

 

Filter fltr = contents("RCR289", false);

set(bm2, fltr);

in which bm2 is the module, but realized that this is looking for RCR289 in the text of the object, which there are none.  And yet, when I ran this code, I still got all the items in the original baseline.  I know I must be doing something wrong, but I'm not sure in that case.  But as I stated earlier, I am really looking for objects whose "*RCR" attribute contains RCR289.  Can someone steer me in the right direction for the example above as well as help me with the filter I really want?

 

Chris


chrscote - Wed Mar 22 11:33:22 EDT 2017

Re: Filter for text attribute that contains certain value
kourosh - Wed Mar 22 13:47:29 EDT 2017

Module m = current
Filter f = contains(attribute "RCR", "RCR289", false)
set f
filtering on

 

Re: Filter for text attribute that contains certain value
chrscote - Wed Mar 22 14:17:08 EDT 2017

kourosh - Wed Mar 22 13:47:29 EDT 2017

Module m = current
Filter f = contains(attribute "RCR", "RCR289", false)
set f
filtering on

 

OK, I have one problem...  I have 2 baselines of the same module open and this code appears to be filtering the incorrect baseline.  Here is my code:

Baseline bm1;
Baseline bm2;
string exportCR(Module m, Baseline b1, Baseline b2) {
    string ver1;
    string ver2;
    string rcrNum;
    Filter fltr
    
    if (null b1) {
        bm1 = m;
        ver1="Current Version"
    } else {
        bm1 = load(m, b1, true);
        ver1 = "Baseline " (major b1) "." (minor b1) (suffix b1 "" != "" ? " (" (suffix b1) ")" : "");
    }
    filtering off;
    sorting off
    
    if (null b2) {
        bm2 = m;
        ver2 = "Current Version";
    } else {
        bm2 = load(m, b2, true);
        ver2 = "Baseline " (major b2) "." (minor b2) (suffix b2 "" != "" ? " (" (suffix b2) ")" : "");
    }
    fltr = contains(attribute "RCR", "289", false);
    set fltr;
    filtering on;
    sorting off;
    
    //Do rest of code not pertinent to this question.
    ...
    ...

}

If I use Current (or the currently opened baseline) for bm2, the code above filters bm1 instead of bm2.

 

Chris

Re: Filter for text attribute that contains certain value
7XUT_Antonio_Norkus - Thu Mar 23 20:10:57 EDT 2017

I think your declarations are wrong...it should start:

Module bm1
Module bm2

Then to filter bm2:

Module oldCurrent = current
current = bm2
// do filter
current = oldCurrent
// so your function doesn't change current on the caller

 

Re: Filter for text attribute that contains certain value
chrscote - Fri Mar 24 07:35:55 EDT 2017

7XUT_Antonio_Norkus - Thu Mar 23 20:10:57 EDT 2017

I think your declarations are wrong...it should start:

Module bm1
Module bm2

Then to filter bm2:

Module oldCurrent = current
current = bm2
// do filter
current = oldCurrent
// so your function doesn't change current on the caller

 

Ah, that might explain it.

Thanks,

Chris